//-------------------------------------------------------------------------------------
function saveSettings()
{
    if(document.getElementById('autoClick').checked == true)
        GM_setValue('autoClick', 'checked');
    else
        GM_setValue('autoClick', '0');

    if(document.getElementById('autoProperty').checked == true)
        GM_setValue('autoProperty', 'checked');
    else
        GM_setValue('autoProperty', '0');

		if(document.getElementById('autoMission').checked == true)
        GM_setValue('autoMission', 'checked');
    else
        GM_setValue('autoMission', '0');
        
		if(document.getElementById('missionMastery').checked == true)
        GM_setValue('missionMastery', 'checked');
    else
        GM_setValue('missionMastery', '0');        

    if(document.getElementById('autoBank').checked == true)
        GM_setValue('autoBank', 'checked');
    else
        GM_setValue('autoBank', '0');

    if(document.getElementById('autoHeal').checked == true)
        GM_setValue('autoHeal', 'checked');
    else
        GM_setValue('autoHeal', '0');

    if(document.getElementById('autoFight').checked == true)
        GM_setValue('autoFight', 'checked');
    else
        GM_setValue('autoFight', '0');

    if(document.getElementById('fightRandom').checked == true)
        GM_setValue('fightRandom', 'checked');
    else
        GM_setValue('fightRandom', '0');

    if(document.getElementById('freshMeat').checked == true)
        GM_setValue('freshMeat', 'checked');
    else
        GM_setValue('freshMeat', '0');

    if(document.getElementById('rFightList').checked == true)
        GM_setValue('rFightList', 'checked');
    else
        GM_setValue('rFightList', '0');

	if(SCRIPT.appID=='app16421175101') //if this is the pirates script
		{
		if(document.getElementById('autoTreasure').checked == true)
			GM_setValue('autoTreasure', 'checked');
		else
			GM_setValue('autoTreasure', '0');   
		}
        
     if(document.getElementById('autoPet').checked == true)
        GM_setValue('autoPet', 'checked');
    else
        GM_setValue('autoPet', '0');        
        
     if(document.getElementById('autoStats').checked == true)
        GM_setValue('autoStats', 'checked');
    else
        GM_setValue('autoStats', '0');          

	if(SCRIPT.appID=='app16421175101') //if this is the pirates script
		{
		if(document.getElementById('autoIsland').checked == true)
			GM_setValue('autoIsland', 'checked');
		else
			GM_setValue('autoIsland', '0');    
		}

     if (document.getElementById('statAtt').checked) {
     	GM_setValue('statUpgrade',document.getElementById('statAtt').value);
     } else if (document.getElementById('statDef').checked) {
     	GM_setValue('statUpgrade',document.getElementById('statDef').value);
     } else if (document.getElementById('statEnergy').checked) {
     GM_setValue('statUpgrade',document.getElementById('statEnergy').value);
     } else if (document.getElementById('statHP').checked) {
     	GM_setValue('statUpgrade',document.getElementById('statHP').value);
     } else if (document.getElementById('statStrength').checked) {
     	GM_setValue('statUpgrade',document.getElementById('statStrength').value);
     } else {
     	GM_setValue('autoStats','0');
     	GM_setValue('statUpgrade','');
     }	
     
	GM_setValue('selectMission', selectMission.selectedIndex );
	GM_setValue('bankConfig', document.getElementById('bankConfig').value);
	GM_setValue('bankKeep', document.getElementById('bankKeep').value);
	GM_setValue('r1', document.getElementById('r1').value);
	GM_setValue('r2', document.getElementById('r2').value);
	GM_setValue('fightMinimum', document.getElementById('fightMinimum').value);
	GM_setValue('fightList', trim(document.getElementById('fightList').value));
	GM_setValue('healthLevel', document.getElementById('healthLevel').value);
	if (document.getElementById('healthLevel').value < killhealth)
		{
		alert("You have selected a minimum health below the level where one attack could kill you (31)." + '\n' +
			"The autoplayer always heals if you're below 31 but above 19 and you have autoHeal" + '\n' +
			"turned on, even if you set this below 31, we pretend you meant to say 31." + '\n' +
			"Setting to a higher value will result in your getting killed less." + '\n' +
			"Just thought you might want to know that we've got your back.");
		}
	GM_setValue('healthRage', document.getElementById('healthRage').value);
	GM_setValue('forceHealHealth', document.getElementById('forceHealHealth').value);
	if (document.getElementById('forceHealHealth').value > document.getElementById('healthLevel').value)
		{
		alert("You have selected a force heal health above your heal health." + '\n' +
			"This means this setting isn't really doing anything." + '\n' +
			"If you don't want to see this when you save, but want this behavior," + '\n' +
			"set these two values equal.");
		}
    GM_setValue('fightLevel', document.getElementById('fightLevel').value);
    GM_setValue('fightClanSize', document.getElementById('fightClanSize').value);

	if(document.getElementById('buyCrewProperty').checked == true)
		GM_setValue('buyCrewProperty', 'checked');
	else
		GM_setValue('buyCrewProperty', '0');  

	if(document.getElementById('buyCrewPropertyUnique').checked == true)
		GM_setValue('buyCrewPropertyUnique', 'checked');
	else
		GM_setValue('buyCrewPropertyUnique', '0');  



    saveNotification.style.visibility = "visible";
    setTimeout("document.location = location.href",1000);
}
